$(() => {
    const loginId = $.cookie('ID');
    const loginToken = $.cookie('Token');

    // console.log(loginId, loginToken);

    function isLogin() {
        if (loginId !== undefined && loginToken !== undefined) {
            return false;
        }
        return true;
    }

    function getNickName() {
        const loginId = $.cookie('NickName');
        $('#login').text(loginId);
    }


    function login() {
        let flg = isLogin();
        // console.log(flg);
        if (flg) {
            $('#login').on('click', () => {
                location.href = 'login.html';
                // console.log('去登录！');
            });
            $('#register').on('click', () => {
                location.href = 'regester.html';
            });
        } else {
            // console.log('已登录');
            getNickName();
            $('#goShop').on('click', () => {
                location.href = 'shopCard.html';
                // console.log('去登录！');
            });
            return true;
        }
    }

    login();

    // $('#register').on('click', () => {
    //     location.href = 'regester.html';
    // });
    $('#listGo').on('click', () => {
        location.href = 'GoodList.html';
    });
    $('#index').on('click', () => {
        location.href = 'index.html';
    })
})